/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fir;

/**
 *
 * @author zhangyucen
 */
public class ChessLine {
    Chess chess;
    int chessLine[][];

    public ChessLine(Chess che) {
        chess = che;
        chessLine = new int[572][2];
    }

    public void Count() {
        int i, j, k;
        for (k = 0; k < 572; k++) {
            chessLine[k][0] = 0;    //black
            chessLine[k][1] = 0;    //white
        }
        for (k = 0; k < 572; k++) {
            for (i = 0; i < 15; i++) {
                for (j = 0; j < 15; j++) {
                    if (chess.tableplayer1[k][i][j] == true && chessLine[k][0] >= 0) {
                        if (chess.point[i][j] == 2) chessLine[k][0] = -1;
                        if (chess.point[i][j] == 1) chessLine[k][0]++;
                    }
                    if (chess.tableplayer2[k][i][j] == true && chessLine[k][1] >= 0) {
                        if (chess.point[i][j] == 1) chessLine[k][1] = -1;
                        if (chess.point[i][j] == 2) chessLine[k][1]++;
                    }
                }
            }
        }
    }
    public int judge() {
        for (int i = 0; i < 572; i++) {
            if (chessLine[i][0] == 5) return 0;
            if (chessLine[i][1] == 5) return 1;
        }
        return -1;
    }
}
